package com.allen.imsystem.message.controller;

import com.allen.imsystem.common.bean.JSONResponse;
import com.allen.imsystem.common.cache.ICacheHolder;
import com.allen.imsystem.message.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @ClassName MessageController
 * @Description
 * @Version 1.0
 */
@RequestMapping("/api/msg")
@RestController
public class MessageController {

    @Qualifier("AttrCacheHolder")
    @Autowired
    private ICacheHolder cacheHolder;

    @Autowired
    private MessageService messageService;

    /**
     * 撤回
     */
    @RequestMapping("/withdraw")
    public JSONResponse withdraw(@RequestParam("talkId") Long talkId, @RequestParam("msgId") Long msgId,
                                 HttpServletRequest request) {
        String uid = cacheHolder.getUid(request);
        messageService.withdraw(talkId, msgId, uid);
        return new JSONResponse(1);
    }

}
